#include<bits/stdc++.h>
using namespace std;

bool is_Leap_year(int year){
    if(year % 100 == 0) return (year/100%4 == 0);
    else return (year%4 == 0);
}

int Not_Leap_year_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int Leap_year_month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main(){
    int year, n;
    while(cin>>year>>n){
        int *m = NULL;
        if(is_Leap_year(year)) m = Leap_year_month;
        else m = Not_Leap_year_month;
        int month = 1;
        int day = n;
        for(int i=0; i<12; ++i){
            if(day <= m[i]) break;
            else {
                day -= m[i];
                ++month;
            }
        }
        printf("%4d-%02d-%02d\n", year, month, day);
    }
    return 0;
}